<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title></title>
</head>
<body>
<!--弹窗：预算激活-->
<div th:fragment="moneyinfodetailActiveEdit" class="modal inmodal fade" id="moneyinfodetailActiveEdit_Modal"
     tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>
                <h4 class="modal-title" id="moneyinfodetailActiveEdit_modalTitle">经费激活</h4>
                <p id="moneyinfodetailActiveEdit_modalDesc" class="font-bold text-danger"></p>
            </div>
            <div class="modal-body">
                <form id="moneyinfodetailActiveEdit_Form">
                    <input id="moneyinfodetailActiveEdit_id" name="id" type="hidden"/>
                    <div class="row">
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_moneyTypeName">经费类型</label>
                            <input class="form-control" id="moneyinfodetailActiveEdit_moneyTypeName"
                                   name="moneyTypeName" disabled/>
                        </div>
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_projectName">预算项目</label>
                            <input class="form-control" id="moneyinfodetailActiveEdit_projectName"
                                   name="projectName" disabled/>
                        </div>
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_cateName">经济分类</label>
                            <input class="form-control" id="moneyinfodetailActiveEdit_cateName"
                                   name="cateName" disabled/>
                        </div>
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_money">金额</label>
                            <input class="form-control" id="moneyinfodetailActiveEdit_money"
                                   name="money" disabled/>
                        </div>
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_moneyActive">激活比例</label>
                            <div class="i-checks">
                                <label> <input type="radio" value="30" name="isWork"> <i></i> 30%
                                </label>&nbsp;&nbsp;
                                <label> <input type="radio" value="50" name="isWork"> <i></i> 50%
                                </label>&nbsp;&nbsp;
                                <label> <input type="radio" value="70" name="isWork"> <i></i> 70%
                                </label>
                                <label> <input type="radio" value="100" name="isWork"> <i></i> 100%
                                </label>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <label for="moneyinfodetailActiveEdit_moneyActive">激活金额</label>
                            <input class="form-control" id="moneyinfodetailActiveEdit_moneyActive"
                                   name="moneyActive"/>
                        </div>
                    </div>
                </form>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="moneyinfodetailActiveEditObj.saveActiveHandle()">
                    激活
                </button>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
            $('.i-checks').on('ifChecked', function (event) {
                let money = parseFloat(moneyinfodetailActiveEditObj.myForm.find(`input[name=money]`).val());
                let rate = parseInt(event.target.value);
                moneyinfodetailActiveEditObj.myForm.find(`input[name=moneyActive]`).val((money*rate/100).toFixed(2));
            });
        })
        var moneyinfodetailActiveEditObj = new Object({
            myForm: $('#moneyinfodetailActiveEdit_Form'),
            myModal: $('#moneyinfodetailActiveEdit_Modal'),
            init: function (id) {
                let _self = this;
                let _myId = id;
                $.myGet({
                    url: `/money/cur/moneyinfodetail/${_myId}`,
                    success: function (data) {
                        if (data && data.code === 0) {
                            let info = data.info;
                            for (let key in info) {
                                if (_self.myForm.find(`input[name=${key}]`).length > 0) {
                                    _self.myForm.find(`input[name=${key}]`).val(info[key])
                                }
                            }
                            _self.myForm.find(`input[name=moneyActive]`).val(_self.myForm.find(`input[name=money]`).val());
                        } else {
                            toastr.error(data.msg, '操作失败')
                        }
                    }
                })
                this.toggleModal(true)
            },
            toggleModal: function (show) {
                this.myModal.modal(show ? 'show' : 'hide');
            },
            saveActiveHandle: function () {
                let _self = this;
                $.mySwalConfirm("将激活预算，确定吗?", function () {
                    toastr.success("激活成功", '操作提示')
                    _self.myModal.modal('hide')
                });
            }
        })
    </script>

</div>
</body>
</html>